/*
 * Created on 2008-06-04
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package elka.isi.gene;

import org.evolvica.core.IGenotype;
import org.evolvica.core.IntegerArrayGene;

/**
 * @author Zibi
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public abstract class AnimalGene extends IntegerArrayGene {

    public static final int GENOME_SIZE = 9;

    public static final int SIZE_GENE = 0;
	public static final int LEGS_LENGTH_GENE = 1;
    public static final int MUSCLE_GENE = 2;
    public static final int EYESIGTH_GENE = 3;
    public static final int HEARING_GENE = 4;
    public static final int SMELL_GENE = 5;
    public static final int SMARTNESS_GENE = 6;
    public static final int MEMORY_GENE = 7;
    public static final int METABOLISM_GENE = 8;

    /* wspolczynniki, przez ktore bedzie sie mnozylo znormalizowane wartosci genow z przedzialu 1 do 100,
       zeby uzyskac "rzeczywiste" wartosci genow charakterystyczne dla danego gatunku (ekspresja genu)
     */
    private double geneRates[] = new double[GENOME_SIZE];

    /**
	 * @param value
	 */
	public AnimalGene(int[] value) {
        super(value);
        if (value.length != GENOME_SIZE)
			throw new IllegalArgumentException(
				"Incorrect genome size! Should be: "
					+ GENOME_SIZE
					+ ", was: "
					+ value.length);

        geneRates[SIZE_GENE] = getSizeRate();
        geneRates[LEGS_LENGTH_GENE] = getLegsLengthRate();
        geneRates[MUSCLE_GENE] = getMuscleRate();
        geneRates[EYESIGTH_GENE] = getEyeSigthRate();
        geneRates[HEARING_GENE] = getHearingRate();
        geneRates[SMELL_GENE] = getSmellRate();
        geneRates[SMARTNESS_GENE] = getSmartnessRate();
        geneRates[MEMORY_GENE] = getMemoryRate();
        geneRates[METABOLISM_GENE] = getMetabolismRate();

    }
	


	/**
	 * @see org.evolvica.core.IGenotype#copy()
	 */
	public abstract IGenotype copy();

	public int getGene(int index){
        double ret = value[index] * geneRates[index];
        return (int) ret + 1;    //stad nie moze pojsc zero
	}

    public int getGenomeSize() {
		return GENOME_SIZE;
	}

    protected abstract double getSizeRate();
    protected abstract double getLegsLengthRate();
    protected abstract double getMuscleRate();
    protected abstract double getEyeSigthRate();
    protected abstract double getHearingRate();
    protected abstract double getSmellRate();
    protected abstract double getSmartnessRate();
    protected abstract double getMemoryRate();
    protected abstract double getMetabolismRate();
}
